using UnityEngine;
using System.Collections;

public class LeavesTrail : MonoBehaviour {

	public GameObject itemPrefab;

	float distance = 0.5f;
	Vector2 lastSpot;

	void Start() {
		lastSpot = transform.position;
	}

	// Update is called once per frame
	void Update () {
		if( Vector2.Distance(lastSpot, transform.position) >= distance) {
			lastSpot = transform.position;
			if(Random.Range(0f, 1f) < 0.33f) {
				Instantiate(itemPrefab,transform.position,Quaternion.identity);
			}
		}
	}
}
